#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
营销 - 商户活动修改功能使用示例
"""

import os
import sys

# 添加项目根目录到Python路径，确保能够导入jlpay包
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from examples.base_example import BaseExample
from jlpay.services.marketing.merchant_activity_update_service import MerchantActivityUpdateService
from jlpay.model.marketing.merchant_activity_update import MerchantActivityUpdateRequest


class MerchantActivityUpdateExample(BaseExample):
    """商户活动修改示例类"""
    
    def __init__(self):
        """初始化商户活动修改示例"""
        super().__init__("examples.marketing.merchant_activity_update")
        self.service = MerchantActivityUpdateService(self.config)
    
    def build_merchant_activity_update_request(self):
        """
        构建商户活动修改请求
        
        Returns:
            MerchantActivityUpdateRequest实例
        """
        request = MerchantActivityUpdateRequest()
        
        # 设置请求参数
        request.set_merch_no("84940535193A026")
        request.set_act_id("act610000064")
        request.set_status("join")
        
        return request
    
    def demo(self):
        """执行商户活动修改示例"""
        self.logger.info("开始执行商户活动修改示例")
        
        # 创建商户活动修改请求
        request = self.build_merchant_activity_update_request()
        
        # 发送请求并处理响应
        response = self.send_request_and_handle_response(
            self.service.merchant_activity_update, 
            "商户活动修改", 
            request
        )
        
        # 处理响应结果
        if response and response.is_success():
            self.logger.info(f"响应报文：{response.to_dict()}")
        
        self.logger.info("商户活动修改示例执行完毕")


if __name__ == "__main__":
    example = MerchantActivityUpdateExample()
    example.logger.info("=" * 50)
    example.logger.info("===== 商户活动修改示例 开始 =====")
    example.logger.info("=" * 50)
    example.demo()
    example.logger.info("=" * 50)
    example.logger.info("===== 商户活动修改示例执行完毕 =====")
    example.logger.info("=" * 50) 